$(function(){
    PatvCustNo = $("#atvCustNo").html().trim()+"";
    atvCustName = $("#atvCustName").html().trim()+"";
    function QueryActivities(atvCustNo) {
        $.ajax({
            type:"post",
            url:"/CusterRelSys/CstActivity/queryActivityByNo",
            data:atvCustNo,
            success:function(Activities){
                console.log(Activities);
                var table=$(".data_list_table");
                table.find("tbody").remove();
                var tr="";
                if(Activities!=null){
                    for(var i in Activities ){
                        tr+=
                            "<tr><td class='list_data_text' width='230'>"+Activities[i].atvDate+"</td>"+
                            "<td class='list_data_text' >"+Activities[i].atvPlace+"</td>"+
                            "<td class='list_data_ltext'>"+Activities[i].atvTitle+"</td>"+
                            "<td class='list_data_ltext' >"+Activities[i].atvDesc+"</td>"+
                            "<td class='list_data_op'>"+Activities[i].atvRemark+"</td>"+
                            '<td class="list_data_op">'+
                            "<img onclick="+"to('~cust/cust/activities_edit.jsp?atvId="+Activities[i].atvId+"&atvCustNo="+PatvCustNo+"&atvCustName="+atvCustName+"');"+'title="编辑" src="images/bt_edit.gif" class="op_button" />&nbsp'+
                            "<a class='am-icon-close' actTatle='"+Activities[i].atvTitle+"' data-id='"+Activities[i].atvId+"' title='删除' >"+'</a>'+
                            '</td></tr>';
                    }
                }
                table.append(tr);
            },error:function(Activities){
                console.log(Activities);

            }
        });
    }

    QueryActivities({"atvCustNo":PatvCustNo});
    function delActivities(atvId) {
        $.ajax({
            type:"post",
            url:"/CusterRelSys/CstActivity/delActivites",
            data:atvId,
            success:function(Activities){
                if(Activities==1){
                    alert("删除成功")
                    QueryActivities({"atvCustNo":PatvCustNo});
                }else{
                    alert("删除失败")
                }
            }
        });
    }
    var $confirm = $('#my-confirm');
    var $confirmBtn = $confirm.find('[data-am-modal-confirm]');
    var $cancelBtn = $confirm.find('[data-am-modal-cancel]');
    $confirmBtn.off('click.confirm.modal.amui').on('click', function() {
        // do something
    });

    $cancelBtn.off('click.cancel.modal.amui').on('click', function() {
        // do something
    });
    act_id=0;
    /*模态框*/
    $('.data_list_table').on('click',".am-icon-close", function(event) {
        act_id=$(this).attr("data-id");
        $('#my-confirm').modal({
        });
    });
    $("#confirm").click(function () {
        delActivities({"atvId":act_id})
    });

})